import { AsyncMipmapGenerator } from './asyncMipmapGenerator';
import { ImageUtils } from './imageUtils';
import { MipmapGenerator } from './mipmapGenerator';
 
export class AsyncMipmapAPI {
    public static async generateMipmap(
        imageUrl: string
    ): Promise<MipmapGenerator> {
        const imageData = await ImageUtils.loadImage(imageUrl);
        const generator = new AsyncMipmapGenerator(
            imageData.data,
            imageData.width,
            imageData.height
        );
        return generator.generate();
    }
 
    public static async convertImage(
        imageUrl: string,
        format: 'jpeg' | 'png' | 'webp'
    ): Promise<string> {
        const imageData = await ImageUtils.loadImage(imageUrl);
        return ImageUtils.convertFormat(
            imageData.data,
            imageData.width,
            imageData.height,
            format
        );
    }
}